<!--
 * @description: 循环树
 * @Author: Coder
 * @Date: 2020-01-06 09:10:50
 * @LastEditors  : Coder
 -->
<template>
  <div>
    <ul class="cursor" v-for="item in data" :key="item.id" @select="selected">
      <li class="mg_t10 hover"><a-icon type="folder" /> {{ item.name }}</li>
      <!-- 部门人员 -->
      <template v-if="Boolean(item.attendEmpInfoList)">
        <ul v-for="peo in item.attendEmpInfoList" :key="peo.id" @click="chosePeo(peo)">
          <li class="mg_t10 hover">
            <a-icon type="user" />
            {{ peo.name }}
          </li>
        </ul>
      </template>

      <!-- 循环childlist -->
      <template v-if="Boolean(item.childList)">
        <tree-selects :data="item.childList"></tree-selects>
      </template>
    </ul>
  </div>
</template>

<script>
export default {
  name: "TreeSelects",

  props: {
    data: {
      type: Array,
      default: () => []
    }
  },
  data() {
    return {
      current: null,

      needData: []
    };
  },

  methods: {
    selected(e) {},

    chosePeo(item) {
      const { deptName: depInfoName, deptId: depInfoId, id: empInfoId, name: empInfoName } = item;
      this.$nextTick(() => {
        this.needData.push({ depInfoName, depInfoId, empInfoId, empInfoName });
        /*  this.$emit("deepChose", this.needData);*/
        /* this.eventBus.$emit("deepChose", this.needData);*/
      });
    }
  }
};
</script>
<style lang="scss" scoped>
.hover {
  position: relative;
  &:hover {
    background: #edf1f5;
  }
}
</style>
